package com.yikaiye.android.yikaiye.ui.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.DataBindingHolder;
import com.yikaiye.android.yikaiye.R;
import com.yikaiye.android.yikaiye.databinding.ItemMainPersonInfoBinding;
import com.yikaiye.android.yikaiye.model.company.GsBaseInfoModel;
import com.yikaiye.android.yikaiye.utils.CommonUtil;

/**
 * 主要人员
 */
public class MainPersonInfoAdapter extends BaseQuickAdapter<GsBaseInfoModel.MainPersonModel, DataBindingHolder<ItemMainPersonInfoBinding>> {

    @Override
    protected void onBindViewHolder(@NonNull DataBindingHolder<ItemMainPersonInfoBinding> itemMainPersonInfoBindingDataBindingHolder, int position, @Nullable GsBaseInfoModel.MainPersonModel mainPersonModel) {
        ItemMainPersonInfoBinding binding = itemMainPersonInfoBindingDataBindingHolder.getBinding();
        if (mainPersonModel != null) {
            if (position % 3 == 0) {
                binding.tvSurname.setBackgroundResource(R.drawable.shape_c5ace9_2dp);
            } else if (position % 3 == 1) {
                binding.tvSurname.setBackgroundResource(R.drawable.shape_d1b194_2dp_bg);
            } else if (position % 3 == 2) {
                binding.tvSurname.setBackgroundResource(R.drawable.shape_93a4e1_2dp);
            } else {
                binding.tvSurname.setBackgroundResource(R.drawable.shape_c5ace9_2dp);
            }
            if (!TextUtils.isEmpty(mainPersonModel.getName())) {
                binding.tvSurname.setText(mainPersonModel.getName().substring(0, 1));
                binding.tvGdName.setText(mainPersonModel.getName());
            }
            binding.tvJobPosition.setText(CommonUtil.setText(mainPersonModel.getJobTitle()));
//            myViewHolder.binding.tvCzbl.setText();
        }
    }

    @NonNull
    @Override
    protected DataBindingHolder<ItemMainPersonInfoBinding> onCreateViewHolder(@NonNull Context context, @NonNull ViewGroup viewGroup, int i) {
        return new DataBindingHolder<>(R.layout.item_main_person_info, viewGroup);
    }
}
